﻿@*他怎么能够保持点击一个新的页面之后保持原来的菜单展开？*@
@model List<SidebarMenu>
@{
    var list = Model ?? new List<SidebarMenu>();
    var url = Url.Action("List", "Menu", null, "http").Replace("/Menu/List", "") + "/";
}
<!-- BEGIN SIDEBAR -->
<div class="page-sidebar-wrapper">
    <div class="page-sidebar navbar-collapse collapse">
        <!-- BEGIN SIDEBAR MENU -->
        <ul class="page-sidebar-menu">
            <li class="sidebar-toggler-wrapper">
                <!-- BEGIN SIDEBAR TOGGLER BUTTON -->
                <div class="sidebar-toggler hidden-phone">
                </div>
                <!-- BEGIN SIDEBAR TOGGLER BUTTON -->
            </li>
            <li class="sidebar-search-wrapper">
                <!-- BEGIN RESPONSIVE QUICK SEARCH FORM -->
                <form class="sidebar-search" action="extra_search.html" method="POST">
                    <div class="form-container">
                        <div class="input-box">
                            <a href="javascript:;" class="remove"></a>
                            <input type="text" placeholder="Search..." />
                            <input type="button" class="submit" value="" />
                        </div>
                    </div>
                </form>
                <!-- END RESPONSIVE QUICK SEARCH FORM -->
            </li>
            <li class="start">
                <a href="@Url.Action("Index", "Home")">
                    <i class="fa fa-home"></i>
                    <span class="title">
                        Home
                    </span>
                </a>
            </li>

            @foreach (var item in list)
            {
                var hasUrl = !string.IsNullOrEmpty(item.Url);
                var itemUrl = hasUrl ? url + item.Url : "javascript:;";
                <li class="">
                    <a href="@itemUrl">
                        <i class="fa fa-cogs"></i>
                        <span class="title">@item.Name</span>

                        @if (item.Childs.Count > 0)
                        {
                            <span class="arrow ">
                            </span>
                        }
                    </a>
                    @if (item.Childs.Count > 0)
                    {
                        <ul class="sub-menu">
                            @foreach (var child in item.Childs)
                            {
                                <li>
                                    <a href="@(url + child.Url)">
                                        <span class="badge badge-roundless badge-important">
                                            new
                                        </span>
                                        @child.Name
                                    </a>
                                </li>
                            }
                        </ul>
                    }
                </li>
            }
        </ul>
        <!-- END SIDEBAR MENU -->
    </div>
</div>
<!-- END SIDEBAR -->